<%@page import="java.util.*"%>
<%@page import="java.text.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 
<%
    String path = request.getContextPath(); 
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+path+ "/"; 
     
%>
<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
	<title>购买积分比例配置</title>
	<link rel="stylesheet" href="bootstrap-3.3.7-dist/css/bootstrap.min.css" />
	<link rel="stylesheet" href="css/bootstrap-datetimepicker.css" />
    <link rel="stylesheet" href="bootstrap-table/dist/bootstrap-table.css">
    <link rel="stylesheet" type="text/css" href="css/xcConfirm.css" />
	<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:400,300" />
	<link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css"/>
	<link rel="stylesheet" href="bootstrap-fileinput-master/css/fileinput.min.css">
    
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="css/font.css">
    <link rel="stylesheet" href="css/xadmin.css">
    
    <style type="text/css">
        #panel {
            position: absolute;
            background-color: white;
            max-height: 90%;
            overflow-y: auto;
            top: 10px;
            right: 10px;
            width: 280px;
        }
        .td1{
			float:left;
			width:50px;
			display: block; 
			valign:middle;
		}
		.td2{
			float:left;
			width:200px;
			display: block; 
			valign:middle;
		}
		.td3{
			float:left;
			width:660px;
			display: block; 
			valign:middle;
		}
    </style>
</head>
<body>
	<div class="x-body">
            <div class="form-horizontal" role="form" style="margin-top: 100px">
              <input id="id" name="id" type="hidden" value="${integral.gId}">
              <div class="col-sm-3" style="width:50px;margin-left: 300px">
		         <input type="text" class="form-control" id="money" name="money" style="width:80px" value="${integral.money}"/>
		      </div>
			  <label for="firstname" class="col-sm-2 control-label" style="width:120px">余额兑换</label>  
			  <div class="col-sm-3" style="width:50px">
		         <input type="text" class="form-control" id="integral" name="integral" style="width:80px" value="${integral.integral}"/>
		      </div> 
		      <label for="firstname" class="col-sm-2 control-label" style="width:110px">积分</label>  
		      
		       <div class="form-group" style="padding-left:-300px;">
			    <label style="margin-left:-200px;" for="firstname" class="col-sm-2 control-label">积分规则:</label>
			     <div class="col-sm-3">
                      <input style="width:800px;" class="form-control" value="${integral.comment}" required="required" id="comment">
                    </div>
			  </div>
     	<div class="form-group" style="padding-left: 30%">
        
        <button type="submit"   onclick="save()"  class="btn btn-info" >更新</button>
   
     </div>
          </div>
	</div>
        <script src="lib/layui/layui.js" charset="utf-8">
        </script>
        <script src="js/x-layui.js" charset="utf-8">
        </script>
        <!-- 加载需要的js -->
		<script src="js/jquery-3.2.1.min.js"></script>
		<script src="js/common2.js"></script>
		<script src="bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
		<script src="js/jquery-bootstrap-pagination.js"></script>
		<script src="js/qunit-1.11.0.js"></script>
		<script src="js/bootstrap-datetimepicker.js"></script>
		<script src="js/bootstrap-datetimepicker.zh-CN.js"></script>
	    <script src="js/xcConfirm.js" type="text/javascript" charset="utf-8"></script>
	    <script src="bootstrap-fileinput-master/js/fileinput.min.js"></script>
		<script src="bootstrap-fileinput-master/js/locales/zh.js"></script>
        <script>
            layui.use(['form','layer','upload'], function(){
                $ = layui.jquery;
              var form = layui.form()
              ,layer = layui.layer;
              });
           
            function save(){
             var id = $("#id").val();
             var comment = $("#comment").val();
           	 var money = $("#money").val();
   			 if(money == null||money=="") {
   				layer.msg('余额不能为空!',{icon:2,time:2000});
				  return ;
   			 }
   		   	 var integral =	$("#integral").val();
   		   	 if(integral == null||integral=="") {
   		   		layer.msg('积分不能为空!',{icon:2,time:2000});
				  return ;
   		   	 }
   		     var re = /^[0-9]+$/ ;  
   		     var reg = /^\d+(?=\.{0,1}\d+$|$)/;
   		     if(!reg.test(money)){
   		    	layer.msg('输入格式不正确!',{icon:2,time:2000});
				  return ;
   		     }
   		     if(!re.test(integral)){
 		    	layer.msg('输入格式不正确!',{icon:2,time:2000});
				  return ;
 		     }
   			 var  data = {"gId":id,"money":money,"type":2,"integral":integral,"comment":comment}
   	         
   	         $.ajax({
   	             type: "post",
   	             url: "integral/addOrUpdate",
   	             data: JSON.stringify(data),
   	             contentType:"application/json;charset=UTF-8", 
   	             dataType:"json",
   	             success: function(data){    
   	           	  if(data.code==200){
   	           	   layer.alert(data.msg, {icon: 6},function () {
   	           		    location.reload();
	                });    
	       }else{
	    	      var txt=data.msg;
	      	    	   layer.alert(txt); 
	      	       }
               }
   	         });  
   	         
   			}
   	   
   	   function cancel(){
   		   	
   		// 获得frame索引
           var index = parent.layer.getFrameIndex(window.name);
           //关闭当前frame
           parent.layer.close(index);
   	         
   			}
        </script>
</body>
</html>